package src.dual_pointers;

/**
 * @author starsea
 * @date 2024-08-26 9:42
 */

public class Test11 {
    public static void main(String[] args) {
        int[] arr={-1,0,3,5,9,12};
        int c=search(arr,9);
    }
    public static int search(int[] nums, int target) {
        int left=0;
        int right=nums.length-1;
        while(left<=right)
        {
            int mid=(left+right)/2;
            int sum=nums[mid];
            if(target<sum)
            {
                right=mid-1;
            }else if(target>sum){
                left=mid+1;
            }else{
                return mid;
            }
        }
        return -1;

    }
}
